package org.karesz.model;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Min;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.karesz.tools.CaseType;
import org.karesz.tools.CheckCase;

@Entity
public class User {

	@Id
	@GeneratedValue
	private long id;
	
	@Size(min=3, max=25, message="Your name should be between 3 - 25 characters.")
	@Pattern(regexp="[A-z ]*", message="Name is invalid!")
	private String name;
	
	@Min(18)
	private int age;
	
	@Past(message="Date of Birth must be in the past")
	private Date dob;
	
	@Size(min=4, max=8, message="Username length must be between 4 and 8 characters")
	@Pattern(regexp="[A-z0-9_-]*", message="Username is invalid!")
	private String username;
	
	@CheckCase(message = "Password must be lowercase", value = CaseType.LOWER)
	@Size(min=4, max=12, message="Password length must be between 4 and 12 characters")
	@Pattern(regexp="[A-z0-9_-]*", message="Password is invalid!")	
	private String password;
	private Rights rights;
	private Date created;
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	
	public Date getCreated() {
		return created;
	}
	public void setCreated(Date created) {
		this.created = created;
	}
	
	public Date getDob() {
		return dob;
	}
	public void setDob(Date dob) {
		this.dob = dob;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public Rights getRights() {
		return rights;
	}
	public void setRights(Rights rights) {
		this.rights = rights;
	}
	@Override
	public String toString() {
		return "JbossUser [id=" + id + ", name=" + name + "]";
	}
	
	
}
